mx.$indicator = null;
mx.indicate = function(p_message, p_options)
{
    if (document.body == null)
    {
        $(function(){
            mx.indicate(p_message, p_options);
        });
    }
    
    if (typeof(p_message) == "object" && typeof(p_options) == "undefined")
    {
        p_options = p_message;
    }
    
    var options = {
        type: "info",
        message: null,
        textAlign: "center",
        duration: 0,
        hideOnClick: true,
        $container: $(document.body)
    };
    $.extend(true, options, p_options);
    
    if (typeof(p_message) == "string")
    {
        options.message = p_message;
    }
    
    var $container = options.$container;
    if (mx.$indicator == null)
    {
        mx.$indicator = $("<div id='indicator'><div id='icon'/><pre id='text'/></pre>");
        mx.$indicator.css("minWidth", 140);
        mx.$indicator.css("maxWidth", "80%");
        mx.$indicator.hide();
        mx.$indicator.borderRadius(12);
        mx.$indicator.click(function(e){
            if (options.hideOnClick)
            {
                mx.$indicator.clearQueue();
                mx.$indicator.fadeOut("fast");
            }
        });
    }
    $container.append(mx.$indicator);
    
    var symbol = mx.utils.SymbolUtil.getSymbol(options.type);

    if (symbol != null)
    {
        mx.$indicator.children("#icon").show();
        mx.$indicator.children("#icon").css("fontFamily", symbol.font);
        mx.$indicator.children("#icon").text(symbol.text);
    }
    else
    {
        mx.$indicator.children("#icon").hide();
    }
    mx.$indicator.find("#text").css("textAlign", options.textAlign);
    mx.$indicator.children("#text").text(options.message);
    mx.$indicator.css("left", 0);
    mx.$indicator.css("top", 0);
    mx.$indicator.centralize();

    mx.$indicator.stop(true, true);
    
    if (options.duration > 0)
    {
        mx.$indicator.show().delay(options.duration).fadeOut(1200);
    }
    else
    {
        mx.$indicator.show();
    }
    return mx.$indicator;
};

mx.info = function(p_message, p_options)
{
    var options = {
        type: "info",
        duration: 2000
    };
    $.extend(true, options, p_options);
    return mx.indicate(p_message, options);
};

mx.warn = function(p_message, p_options)
{
    var options = {
        type: "warn",
        duration: 10000
    };
    $.extend(true, options, p_options);
    return mx.indicate(p_message, options);
};

mx.error =function(p_message, p_options)
{
    var options = {
        type: "error"
    };
    $.extend(true, options, p_options);
    return mx.indicate(p_message, options);
};